package cn.powerone.scm.controller;

import java.util.List;

import cn.powerone.scm.domain.ScmInquiriesIn;
import cn.powerone.scm.domain.ScmProducts;
import cn.powerone.scm.service.IScmInquiriesInService;
import cn.powerone.scm.service.IScmProductsService;
import cn.powerone.scm.upload.domain.ScmImportInquiriesIn;
import cn.powerone.scm.upload.service.IScmImportInquiriesInService;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import cn.powerone.common.annotation.Log;
import cn.powerone.common.core.controller.BaseController;
import cn.powerone.common.core.domain.AjaxResult;
import cn.powerone.common.enums.BusinessType;
import cn.powerone.scm.domain.ScmProjectProducts;
import cn.powerone.scm.service.IScmProjectProductsService;
import cn.powerone.common.utils.poi.ExcelUtil;
import cn.powerone.common.core.page.TableDataInfo;

/**
 * 项目产品需求Controller
 * 
 * @author PowerOne
 * @date 2025-06-27
 */
@RestController
@RequestMapping("/scm/scmProjectProducts")
public class ScmProjectProductsController extends BaseController
{
    @Autowired
    private IScmProjectProductsService scmProjectProductsService;

    @Autowired
    private IScmInquiriesInService scmInquiriesInService;

    @Autowired
    private IScmProductsService scmProductsService;

    /**
     * 查询项目产品需求列表
     */
    @PreAuthorize("@ss.hasPermi('scm:scmProjectProducts:list')")
    @GetMapping("/list")
    public TableDataInfo list(ScmProjectProducts scmProjectProducts)
    {
        startPage();
        List<ScmProjectProducts> list = scmProjectProductsService.selectScmProjectProductsList(scmProjectProducts);
        return getDataTable(list);
    }

    /**
     * 导出项目产品需求列表
     */
    @PreAuthorize("@ss.hasPermi('scm:scmProjectProducts:export')")
    @Log(title = "项目产品需求", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ScmProjectProducts scmProjectProducts)
    {
        List<ScmProjectProducts> list = scmProjectProductsService.selectScmProjectProductsList(scmProjectProducts);
        ExcelUtil<ScmProjectProducts> util = new ExcelUtil<ScmProjectProducts>(ScmProjectProducts.class);
        util.exportExcel(response, list, "项目产品需求数据");
    }

    /**
     * 获取项目产品需求详细信息
     */
    @PreAuthorize("@ss.hasPermi('scm:scmProjectProducts:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(scmProjectProductsService.selectScmProjectProductsById(id));
    }

    /**
     * 新增项目产品需求
     */
    @PreAuthorize("@ss.hasPermi('scm:scmProjectProducts:add')")
    @Log(title = "项目产品需求", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ScmProjectProducts scmProjectProducts)
    {
        return toAjax(scmProjectProductsService.insertScmProjectProducts(scmProjectProducts));
    }

    /**
     * 修改项目产品需求
     */
    @PreAuthorize("@ss.hasPermi('scm:scmProjectProducts:edit')")
    @Log(title = "项目产品需求", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ScmProjectProducts scmProjectProducts)
    {
        return toAjax(scmProjectProductsService.updateScmProjectProducts(scmProjectProducts));
    }

    /**
     * 删除项目产品需求
     */
    @PreAuthorize("@ss.hasPermi('scm:scmProjectProducts:remove')")
    @Log(title = "项目产品需求", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(scmProjectProductsService.deleteScmProjectProductsByIds(ids));
    }
}
